{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.72080806, 0.29877885],\n",
       "       [0.72730196, 0.85017182],\n",
       "       [0.19399735, 0.45969408],\n",
       "       [0.48361464, 0.84198249]])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "data=np.array(np.random.random(size=(4,2)))\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sklearn.neighbors"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.05773015488683665 0.24027100300876228\n"
     ]
    }
   ],
   "source": [
    "data = data[:,1]\n",
    "a = np.var(data)\n",
    "b = np.std(data)\n",
    "print(a,b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.        , 1.        , 0.29183403, 0.98514792])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def ping(x):\n",
    "    y = [(i-min(x))/(max(x)-min(x)) for i in x]\n",
    "    return y\n",
    "np.apply_along_axis(ping,0,data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.        , 1.        , 0.29183403, 0.98514792])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from my_sklearn.my_knn import My_knn\n",
    "my=My_knn()\n",
    "np.apply_along_axis(my.mymax,0,data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.29877885 0.85017182 0.45969408 0.84198249]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([-5.43698458,  4.11422787, -2.64961577,  3.97237248])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def ping(x):\n",
    "    return [(i-np.mean(x))/np.var(x) for i in x]\n",
    "print(data)\n",
    "np.apply_along_axis(ping,0,data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-1.30634974  0.98852966 -0.63662584  0.95444592] [-5.43698458  4.11422787 -2.64961577  3.97237248]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "from my_sklearn.my_knn import My_knn\n",
    "a=np.apply_along_axis(My_knn.mean_var,0,data)\n",
    "b=np.apply_along_axis(My_knn.mean_var1,0,data)\n",
    "print(a,b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a\n",
      "Wall time: 0 ns\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "print('a')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
